package com.dhwl.hsh.driver.ui.fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.dhwl.hsh.driver.R;
import com.dhwl.hsh.driver.ui.adapter.OrderListAdapter;
import com.dhwl.hsh.lib.bean.resp.OrderListResponse;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;


/**
 * 订单列表
 *
 * @author Derek.Kidd
 * @time 2016/4/22 16:09
 */
public class OrderListFragment extends BaseFragment {

    @Bind(R.id.pull_refresh_list)
    PullToRefreshListView  pullToRefreshListView;

    OrderListAdapter orderListAdapter;

    List<OrderListResponse> orderListResps;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_order_list;
    }

    @Override
    protected void initViews(View self, Bundle savedInstanceState) {

    }

    @Override
    protected void initData() {

        orderListResps = new ArrayList<>();
        orderListResps.add(new OrderListResponse());
        orderListResps.add(new OrderListResponse());
        orderListAdapter = new OrderListAdapter(getActivity(),orderListResps);
        pullToRefreshListView.setAdapter(orderListAdapter);

        pullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
              new Thread(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          Thread.sleep(5000);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                  }
              }).start();
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {

            }
        });

    }

}
